$(document).ready(function () {
	$(".re_right").onePageNav();

$(".bd_bkxz .sec1_bottom .label_w175").next('p').css('width','100px')
	
//添加提示	该字段不能为空
$(".container .re_sec input[type='text']").after("<p class='emptytips'>该字段不能为空</p>");
$(".container .re_sec .selectWrap .select_box span").after("<p class='emptytips'>该字段不能为空</p>");
$(".container .re_sec .nationality_xl span,.container .re_sec .country_xl span,.container .re_sec .province_xl span,.container .re_sec .city_xl span,.container .re_sec .education_xl span,.container .re_sec .degree_xl span").after("<p class='emptytips'>该字段不能为空</p>");
$(".container .re_sec .certificate span,.container .re_sec .provincel_xl span,.container .re_sec .cityl_xl span").after("<p class='emptytips'>该字段不能为空</p>");
$(".container .re_sec textarea").after("<p class='emptytips' style='margin-top:-12px'>该字段不能为空</p>");

//简版简历添加提示

$(".simplified .nationality_xl .select_box2 span,.simplified .education_xl  .select_box2 span").after("<p class='emptytips'>该字段不能为空</p>");
$(".simplified .container .selectWrap1 .select_box1 span").after("<p class='emptytips'>该字段不能为空</p>");
$(".simplified .container .selectWrap  .select_box span").after("<p class='emptytips'>该字段不能为空</p>");
$(".simplified input[type='text']").after("<p class='emptytips'>该字段不能为空</p>");

$(".emptytips").hide();
$(".re_l_sec1_form .sec1_bottom li").eq(0).find('.emptytips').show();
//起止日期
$(".markTime").next(".emptytips").css('margin-left','170px');

$(".container .re_sec input[type='text']").live('blur',function(){
	if($(this).val()!=""){
		$(this).next(".emptytips").hide();
	}
})
$(".container .selectWrap .select_box span").live('click',function(){
	$(this).next(".emptytips").hide();
})
//提示截止

$(".upload_word").hide();
 $('.upload_img').hover(function(event) {
 	var form1 = $(this).find(".upload_word");
   	if(form1.is(':visible')){
   		return;
   	}
 	$(".upload_word").show();
 },function(){
 	$(".upload_word").hide();
 });
 
$('.son_ul1').hide();
var assets_class;//获取点击的父元素的class
//级联选择国家，省份，城市
var jobChoice=[
    	{countryName:"A",province:[{provinceName:"A1",city:[{cityName:"A11"},{cityName:"A12"}]},{provinceName:"A2",city:[{cityName:"A21"},{cityName:"A22"}]}]},
    	{countryName:"B",province:[{provinceName:"B1",city:[{cityName:"B11"},{cityName:"B12"}]},{provinceName:"B2",city:[{cityName:"B21"},{cityName:"B22"}]}]},
    	{countryName:"C",province:[{provinceName:"C1",city:[{cityName:"C11"},{cityName:"C12"}]},{provinceName:"C2",city:[{cityName:"C21"},{cityName:"C22"}]}]}
];

 $('.select_box1 span').live('click',function () { 
 	assets_class=$(this).parents('.selectWrap1').attr('class');
 	var self=$(this);
 	if(assets_class.indexOf('country_xl')>0){
// 		说明选择的国家,任何情况下都可以选择		
		canClick();
 	}else if(assets_class.indexOf('province_xl')>0){
 		if(self.parents('.cascade_select').find(".country_xl li span").text()!=""){
			canClick();
 		}
 	}else if(assets_class.indexOf('city_xl')>0){
 		if(self.parents('.cascade_select').find(".province_xl li span").text()!=""){
			canClick();
 		}
 	}else if(assets_class.indexOf('provincel_xl')>0){
 		canClick();
 	}else if(assets_class.indexOf('cityl_xl')>0){
 		if(self.parents('.expect_city').find(".provincel_xl li span").text()!=""){
			canClick();
 		}		
 	}

 	
 	function canClick(){
 		self.parent().css({"zIndex":"555"})
	    self.parent().find('ul.son_ul1').slideDown();
	    self.parent().find('li').hover(function () {
	        self.addClass('hover')
	    }, function () {
	        self.removeClass('hover')
	    });
	    self.parent().hover(function () {
	        },
	        function () {
	            self.parent().find("ul.son_ul1").slideUp(10);
	            self.parent().find("li.select_box1").css({"zIndex":"0"})
	        }
	    );
 	}
    
});


 $('ul .son_ul1 li').live('click',function () {
 	
// 	如果是从国家选择过来的,则清空后两个
//	获取点击的父元素的class
	assets_class=$(this).parents('.selectWrap1').attr('class');
	if(assets_class.indexOf('country_xl')>0){
		if($(this).parents('.cascade_select').find(".province_xl li span").text()!="省"){
			$(this).parents('.cascade_select').find(".province_xl li span").css('color',"#bbbbbb");
			$(this).parents('.cascade_select').find(".province_xl li span").text("省");
		}
		if($(this).parents('.cascade_select').find(".city_xl li span").text()!="市"){
			$(this).parents('.cascade_select').find(".city_xl li span").css('color',"#bbbbbb");
			$(this).parents('.cascade_select').find(".city_xl li span").text("市");
		}
	}else if(assets_class.indexOf('province_xl')>0){
		if($(this).parents('.cascade_select').find(".city_xl li span").text()!="市"){
			$(this).parents('.cascade_select').find(".city_xl li span").css('color',"#bbbbbb");
			$(this).parents('.cascade_select').find(".city_xl li span").text("市");
		}
	}else if(assets_class.indexOf('provincel_xl')>0){
		if($(this).parents('.expect_city').find(".cityl_xl li span").text()!="市"){
			$(this).parents('.expect_city').find(".cityl_xl li span").css('color',"#bbbbbb");
			$(this).parents('.expect_city').find(".cityl_xl li span").text("市");
		}
	}		
	$(this).parents('.selectWrap1 li').find('span').css('color',"#000000")
    $(this).parents('.selectWrap1 li').find('span').html($(this).html());
    $(this).parents('.selectWrap1 li').find('ul').slideUp(10);
    $(this).parents('.selectWrap1 li').css({"zIndex":"0"});    
});

// 国家选择
$(".country_xl").live('click',function(){
	$(this).find('.son_ul1').empty();
	for(var i in jobChoice){
		var countryHtml='<li>'+jobChoice[i].countryName+'</li>';
		$(this).find('.son_ul1').append(countryHtml);
	}
})
  //省份选择
  $(".province_xl").live('click',function(){
  	$(this).find('.son_ul1').empty();
  	var countryName=$(this).parents('.cascade_select').find('.country_xl .select_box1 span').text();
  	for(var j in jobChoice){
  		if(jobChoice[j].countryName==countryName){
  			for(var k=0;k<jobChoice[j].province.length;k++){
  					var provinceHtml='<li>'+jobChoice[j].province[k].provinceName+'</li>';
  					$(this).find('.son_ul1').append(provinceHtml);      				
  			}
  		}
  	}
  })
//	城市选择
$(".city_xl").live('click',function(){
		$(this).find('.son_ul1').empty();
			var countryName=$(this).parents('.cascade_select').find('.country_xl .select_box1 span').text();
			var provinceName=$(this).parents('.cascade_select').find('.province_xl .select_box1 span').text();		
			for(var i=0;i<jobChoice.length;i++){
  		if(jobChoice[i].countryName==countryName){
  			for(var k=0;k<jobChoice[i].province.length;k++){
  					if(jobChoice[i].province[k].provinceName==provinceName){
  						for(var n=0;n<jobChoice[i].province[k].city.length;n++){
  							var cityHtml='<li>'+jobChoice[i].province[k].city[n].cityName+'</li>';
							$(this).find('.son_ul1').append(cityHtml);     
  						}
  					}
  			}
  		}
}
})
    
    
//面试地点,二级级联.省——市
var jobLocation=[
    	{lprovinceName:"A",lcity:[{lcityName:"A1"},{lcityName:"A2"},{lcityName:"A3"}]},
    	{lprovinceName:"B",lcity:[{lcityName:"B1"},{lcityName:"B2"},{lcityName:"B3"}]},
    	{lprovinceName:"C",lcity:[{lcityName:"B1"},{lcityName:"B2"},{lcityName:"B3"}]},    	
];
//面试地点选择省
$(".provincel_xl").live('click',function(){
	$(this).find('.son_ul1').empty();
	for(var i in jobLocation){
		var lprovinceHtml='<li>'+jobLocation[i].lprovinceName+'</li>';
		$(this).find('.son_ul1').append(lprovinceHtml);
	}
})

//面试地点市选择
  $(".cityl_xl").live('click',function(){
  	$(this).find('.son_ul1').empty();
  	var lprovinceName=$(this).parents('.expect_city').find('.provincel_xl .select_box1 span').text();
  	for(var j in jobLocation){
  		if(jobLocation[j].lprovinceName==lprovinceName){
  			for(var k=0;k<jobLocation[j].lcity.length;k++){
  					var citylHtml='<li>'+jobLocation[j].lcity[k].lcityName+'</li>';
  					$(this).find('.son_ul1').append(citylHtml);      				
  			}
  		}
  	}
  })
	
//导航栏悬浮
    var oTops = 129;
    var sTops = 0;
    var sLeft = 0;
    var diff = $(window).width()-1100;
    var right = ($(window).width()-1100)/2 >0 ?($(window).width()-1100)/2:diff;
    $(window).resize(function(){
    	diff = $(window).width()-1100;
    	right = ($(window).width()-1100)/2 >0 ?($(window).width()-1100)/2:diff;
    	sTops = $(this).scrollTop();
        if(sTops >= oTops){
        	if(sTops>=($(document).height() - $(window).height()-200)){
        		$(".re_right").css('top',"");
        		$(".re_right").css({'position':'absolute','right':'0px','bottom':'10px'});
        	}else{
        		$(".re_right").css({'position':'fixed','right':right,'top':'0px'});
        	}            
        }else{
        	$(".re_right").css({'position':'absolute','right':'0px','top':'0px'});
        }
    });
    $(window).scroll(function(){
        sTops = $(this).scrollTop();
        sLeft = $(this).scrollLeft();
        right = ($(window).width()-1100)/2 >0 ?($(window).width()-1100)/2:diff+sLeft;

        if(sTops >= oTops){
        	if(sTops>=($(document).height() - $(window).height()-200)){
        		$(".re_right").css('top',"");
        		$(".re_right").css({'position':'absolute','right':'0px','bottom':'10px'});
        	}else{
        		$(".re_right").css({'position':'fixed','right':right,'top':'0px'});
        	}            
        }else{
        	$(".re_right").css({'position':'absolute','right':'0px','top':'0px'});
        }
    });
    // $(window).scroll(function(){
    //     sTops = $(this).scrollTop();
    //     console.log()
    //     if(sTops >= oTops){
    //     	if(sTops>=($(document).height() - $(window).height()-200)){
    //     		$(".re_right").css('top',"");
    //     		$(".re_right").css({'position':'absolute','right':'0px','bottom':'10px'});
    //     	}else{
    //     		$(".re_right").css({'position':'absolute','right':'0px','top':(sTops-oTops)+'px'});
    //     	}            
    //     }else{
    //     	$(".re_right").css({'position':'absolute','right':'0px','top':'0px'});
    //     }
    // });


    
//  将底部的预览隐藏
    $(".gezx_preview").remove();
    

})
//添加提示的方法
function tipsAdd(self){
	var modelLen=self.closest('.re_sec').find('.item').length;
	var model_add=self.parents(".re_sec").find('.item').eq(modelLen-1);	 	
 	model_add.find("input[type='text']").after("<p class='emptytips'>该字段不能为空</p>");
	model_add.find(".selectWrap .select_box span").after("<p class='emptytips'>该字段不能为空</p>");
	model_add.find(".nationality_xl span,.country_xl span,.province_xl span,.city_xl span,.education_xl span,.degree_xl span").after("<p class='emptytips'>该字段不能为空</p>");
	model_add.find(".certificate span,.provincel_xl span,.cityl_xl span").after("<p class='emptytips'>该字段不能为空</p>");
	model_add.find("textarea").after("<p class='emptytips' style='margin-top:-12px'>该字段不能为空</p>");
	model_add.find(".markTime").next(".emptytips").css('margin-left','170px');
	$(".emptytips").hide();
}
